<?php

/**
 * This is the model class for table "{{transaksi_ski}}".
 *
 * The followings are the available columns in table '{{transaksi_ski}}':
 * @property integer $id
 * @property integer $id_transaksi
 * @property integer $id_divisi
 * @property string $nota_dinas_no
 * @property string $nota_dinas_tangggal
 * @property string $ski_no
 * @property string $ski_tangggal
 * @property string $kontrak_no
 * @property string $kontrak_periode_awal
 * @property string $kontrak_periode_akhir
 * @property string $kontrak_uraian
 * @property string $kwitansi_no
 * @property string $kwitansi_tanggal
 * @property string $bukti_bayar_no
 * @property string $bukti_bayar_tanggal
 *
 * The followings are the available model relations:
 * @property Divisi $idDivisi
 * @property Transaksi $idTransaksi
 */
class TransaksiSki extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return TransaksiSki the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{transaksi_ski}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_transaksi, id_divisi', 'required'),
			array('id_transaksi, id_divisi', 'numerical', 'integerOnly'=>true),
			array('id_divisi','length', 'min'=>1),
			array('nota_dinas_tangggal, ski_tangggal, kontrak_periode_awal,kontrak_periode_akhir, kwitansi_tanggal, bukti_bayar_tanggal', 'date', 'format'=>'yyyy-MM-dd'),
			array('kontrak_periode_akhir', 'compare', 'compareAttribute' => 'kontrak_periode_awal', 'operator' => '>'),
			array('nota_dinas_no, ski_no, kwitansi_no, bukti_bayar_no', 'length', 'max'=>25),
			array('kontrak_no', 'length', 'max'=>20),
			array('kontrak_uraian', 'length', 'max'=>120),
			array('nota_dinas_tangggal, ski_tangggal, kontrak_periode_awal, kontrak_periode_akhir, kwitansi_tanggal, bukti_bayar_tanggal', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, id_transaksi, id_divisi, nota_dinas_no, nota_dinas_tangggal, ski_no, ski_tangggal, kontrak_no, kontrak_periode_awal, kontrak_periode_akhir, kontrak_uraian, kwitansi_no, kwitansi_tanggal, bukti_bayar_no, bukti_bayar_tanggal', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idDivisi' => array(self::BELONGS_TO, 'Divisi', 'id_divisi'),
			'idTransaksi' => array(self::BELONGS_TO, 'Transaksi', 'id_transaksi'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_transaksi' => 'Id Transaksi',
			'id_divisi' => 'Divisi',
			'nota_dinas_no' => 'No Nota Dinas ',
			'nota_dinas_tangggal' => 'Tanggal Nota Dinas',
			'ski_no' => 'No SKI',
			'ski_tangggal' => 'Tanggal SKI',
			'kontrak_no' => 'No Kontrak ',
			'kontrak_periode_awal' => 'Periode Awal Kontrak',
			'kontrak_periode_akhir' => 'Periode Akhir Kontrak',
			'kontrak_uraian' => 'Uraian Kontrak ',
			'kwitansi_no' => 'No Kwitansi',
			'kwitansi_tanggal' => 'Tanggal Kwitansi',
			'bukti_bayar_no' => 'No Bukti Bayar',
			'bukti_bayar_tanggal' => 'Tanggal Bukti Bayar',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('id_transaksi',$this->id_transaksi);
		$criteria->compare('id_divisi',$this->id_divisi);
		$criteria->compare('nota_dinas_no',$this->nota_dinas_no,true);
		$criteria->compare('nota_dinas_tangggal',$this->nota_dinas_tangggal,true);
		$criteria->compare('ski_no',$this->ski_no,true);
		$criteria->compare('ski_tangggal',$this->ski_tangggal,true);
		$criteria->compare('kontrak_no',$this->kontrak_no,true);
		$criteria->compare('kontrak_periode_awal',$this->kontrak_periode_awal,true);
		$criteria->compare('kontrak_periode_akhir',$this->kontrak_periode_akhir,true);
		$criteria->compare('kontrak_uraian',$this->kontrak_uraian,true);
		$criteria->compare('kwitansi_no',$this->kwitansi_no,true);
		$criteria->compare('kwitansi_tanggal',$this->kwitansi_tanggal,true);
		$criteria->compare('bukti_bayar_no',$this->bukti_bayar_no,true);
		$criteria->compare('bukti_bayar_tanggal',$this->bukti_bayar_tanggal,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}